import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * @version v1.0
 * @Description:
 * @Author zhanzhongxin
 * @Date 2021/7/8 18:11
 * @Copyright 博为峰
 */
public class trywithr {
    public static void main(String[] args) {
        try (Scanner scanner = new Scanner(new File("H:\\TestProject\\src\\main\\java\\com\\chen\\test.txt"));
             PrintWriter writer = new PrintWriter(new File("H:\\TestProject\\src\\main\\java\\com\\chen\\testWrite.txt"))
        ) {
            while (scanner.hasNext()) {
                //test.txt文件的内容写入到test2中
                writer.println(scanner.nextLine());
            }
        } catch (FileNotFoundException file) {
            file.printStackTrace();
        }
    }
}
